﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;

namespace FruitWeigher
{
    public class GSystem
    {
        public static bool IsStartShow { get; set; }
		public const string GUID = "";
        public static Random GamesRandom = new Random((int)DateTime.Now.Ticks);
        public static MainPage Root = null;
        public static UIEndMessageBox UIEndMessageBox = null;
        public static UISelected UISelected = null;
        public static UIProgress UIProgress = null;
        public static HighestScore HighestScore = null;
        public static void SetHighestScore(int score)
        {
            IsolatedStorageSettings storage = IsolatedStorageSettings.ApplicationSettings;
            if (storage.Contains("HighestScore"))
            {
                storage["HighestScore"] = score;               
                
            }
            else
            {
                storage.Add("HighestScore", score);
            }
            if(storage.Contains("LastTime"))
                storage["LastTime"] = DateTime.Now.Ticks;            
            else
                storage.Add("LastTime", DateTime.Now.Ticks);
            storage.Save();
        }
        public static int GetHighestScore()
        {
            int score = 0;
            IsolatedStorageSettings storage = IsolatedStorageSettings.ApplicationSettings;
            if (storage.Contains("HighestScore"))
            {
                score = (int)storage["HighestScore"];
            }
            return score;
        }
        public static string GetLastTime()
        {
            string s = "";
            IsolatedStorageSettings storage = IsolatedStorageSettings.ApplicationSettings;
            if (storage.Contains("LastTime"))
            {
                s = new DateTime((long)storage["LastTime"]).ToString("yyyy/mm/dd hh:mm") ;
            }
            return s;
        }
    }
}
